<?php

class hotnews_controller extends controller {

    public $current = "index";

    public function __construct() {
        parent::__construct();
        spider::write($GLOBALS['W']['id']);
    }

    public function _empty() {
        $url = $this->rest_uri;
        $page = 1;
        if (preg_match("#hotnews-(.*)\.html?#", $url, $mt)) {
            if(!empty($mt[1])) {
                $ms= explode('-',$mt[1]);
                $tagid = urldecode($ms[0]);
                if(!empty($ms[1]) && $ms[1]>1) {
                    $page = intval($ms[1]);
                }
            }
        } else {
            $this->page_404();
        }
        $x = 5;
        //查询标签
        $yuming_id = $this->yuming_website['id'];
        if(is_numeric($tagid) && intval($tagid)==$tagid) {
            $tag = db::find("select id,tagsname from tagslist_{$yuming_id} where id='$tagid' and  yuming_id='" . $this->yuming_website['id'] . "'");
        }else {
            $tag = db::find("select id,tagsname from tagslist_{$yuming_id} where tagsname='$tagid' and  yuming_id='" . $this->yuming_website['id'] . "'");
        }
        if (!$tag) {
            $this->page_404();
        }
        $GLOBALS['tagid'] = $tagid;
        //查询文章

        $title = $tag['tagsname'];

        $pagetitle = $title . '-' . $this->yuming_website['sitename'];
        $keywords = $this->yuming_website['keywords'];
        $description = $this->yuming_website['description'];

        require $this->tpl('taglist');
    }

    public function taglist() {
        $url = $this->rest_uri;
        //查询标签
        $yuming_id = $this->yuming_website['id'];
        $pagetitle = '标签列表' . '-' . $this->yuming_website['sitename'];
        $keywords = $this->yuming_website['keywords'];
        $description = $this->yuming_website['description'];
        require $this->tpl('alltags');
    }

}
